/*******************************************************************
REPLICATION FILE FOR:
Paper: “Class, Ethnicity, and Cooperation Among Women: Evidence from a Public Goods Experiment in Lebanon”
Authors: Leslie Marshall and Laura Paler

This do file calls the raw data and performs initial cleaning and recoding prior to 
the missing data imputation. 
********************************************************************/


*******************************************************
*SET GLOBAL DIRECTORIES
*******************************************************

*Set your personal working directory here: cd~
	cd ~/

	global dos "DOs_and_ADOs"
	global packages "DOs_and_ADOs/PACKAGES"

	global data_orig "DATA/ORIG"
	global data_newimp "DATA/NEW_IMPUTE"
	global working "DATA/NEW_IMPUTE/WORKING"

	global results "RESULTS" 
	global results_figs "RESULTS/FIGS"
	global results_tables "RESULTS/TABLES"

	set more off

***********************************************************
*CALL DATA
***********************************************************

	use "$data_newimp/Leb_0_Preimpute", clear
	
***********************************************************
*PRE-IMPUTATION RECODING
***********************************************************

*SCREENING SURVEY

recode scr_q5_regdistrict (101/103 201/206=1) (301/304 401 501 601 602 =2) (701/703 801/803=3), g(scr_q5_regdistrict_REC1)
		lab def SCR_Q5_R 1 "Beirut/Mt. Leb" 2 "North/Bekaa" 3 "Nabatiye/South" 
		lab val scr_q5_regdistrict_REC1 SCR_Q5_R
		
		
recode scr_q7_iga_final (97 99=.), g(scr_q7_iga_final_REC1)
recode scr_q7_iga_final_REC1 (35=0) (1=1) (3 4 5 6=2) (7=3) (8 9 10 11 12 18 27 28=4) (14 15 17 19 20 21 24 26 29 39 41=5) (22=6) (23=7) (40=8) (97=97) (99=99), g(scr_q7_iga_final_REC3)
recode scr_q7_iga_final_REC3 (0 8 = 0) (1=1) (2=2) (3=3) (4=4) (5=5) (6/7=6), g(scr_q7_iga_final_REC4)
		lab def SCR_Q7_REC4 	0 "No income generating activity" 1 "General/corporate manager" 2 "Specialist" 3 "Self-employed/business owner" 4 "Office employee/service sector" 5 "Skilled worker" 6 "Unskilled worker" 
		lab val scr_q7_iga_final_REC4 SCR_Q7_REC4

recode scr_q1_gender (1=0) (2=1), g(scr_q1_gender_REC2)
		lab def SCR_Q1_v2 0 "Male" 1 "Female", modify
		lab val scr_q1_gender_REC2 SCR_Q1_v2

recode scr_q3_marital (97=.), g(scr_q3_marital_REC1)
		lab def SCR_Q3	1 "Single" 2 "Married" 3 "Divorced" 4 "Widowed" 5 "Divorced" 7 "Other" 97 "Refused", modify
		lab val scr_q3_marital_REC1 SCR_Q3
		
recode scr_q4_educ (10=.), g(scr_q4_educ_REC1)
		lab def SCR_Q4	1 "No formal schooling" 2 "Primary School" 3 "Primary Technical" 4 "Middle School" 5 "Middle Technical" ///
						6 "High School" 7 "Technical Degree" 8 "Bachelor's" 9 "Master's or PhD" 10 "Other" , modify 
		lab val scr_q4_educ_REC1 SCR_Q4

		
recode scr_q6_work (1=4) (4=3) (3=2) (2 5 6 7=1), g(scr_q6_work_REC1)
		lab def SCR_Q6_R 1 "No job and seeking work" 2 "Employed and seeking work" 3 "Employed and not seeking work" 4 "No job and not seeking work"	
		lab val scr_q6_work_REC1 SCR_Q6_R
		
recode scr_q9_assets (96 97 99=.), g(scr_q9_assets_REC1)
		lab def SCR_Q9	1 "0-250,000 USD" 2 "250,001-500,000 USD" 3 "500,001+ USD" 96 "Don't know" 97 "Refused" 99 "Not applicable", modify
		lab val scr_q9_assets_REC1 SCR_Q9
		
recode scr_q14_dineout (99=.), g(scr_q14_dineout_REC1)
			lab def SCR_Q14	1 "0 times" 2 "1-2 times" 3 "3+ times" 99 "Not applicable", modify
			lab val scr_q14_dineout_REC1 SCR_Q14
			
recode scr_q16_income_subj (99=.), g(scr_q16_income_subj_REC1)
			lab def SCR_Q16 1 "Doesn't cover our needs & face major problems" 2 "Barely covers our needs & sometimes face problems" ///
							3 "Covers our needs but can't afford luxuries or extra activities" 4 "Covers our needs without facing any major difficulties" ///
							5 "Very well covers our needs & also save some" 99 "Not applicable", modify
			lab val scr_q16_income_subj_REC1 SCR_Q16
			
*PRE-TREATMENT SURVEY
	lab def PRE_Q15_REC 0 "Nothing" 1 "Increase in prices" 2 "Increased unemployment" 3 "Increase in public deficit" 4 "Developing the oil and gas sector"  ///
							5 "Lack of support for manufacturing" 6 "Increased health/education costs" 7 "Electricity/water supply" 8 "Local development" ///
							9 "Public transport" 10 "Inequality" 11 "General economic concerns" 12 "Increased poverty rates" 13 "Food safety" 14 "Increased radicalization"  ///
							15 "Reforming judicial system" 16 "Electoral reform" 17 "Fighting corruption" 18 "Sectarianism" 19 "Increased crime rates" ///
							20 "Garbage crisis" 21 "General social concerns" 22 "Fear of civil war" 23 "Fear of war with Israel" 24 "Instability in certain regions" ///
							25 "Spread of personal weapons" 26 "Armed groups" 27 "Terrorism" 28 "Other" 29 "General security concerns" 30 "General political crisis" ///
							31 "Lack of interpersonal ethics" 32 "Spread of disease/health crisis" 33 "Status of Lebanese Universities" 34 "Immigration/Refugees/Syria" ///
							35 "Inefficient agricultural sector" 36 "Pension/retirement/social security" 37 "Marriage-related concerns" ///
							96 "Don't know" 97 "Refused" 99 "Not applicable", modify
			* first biggest concern 
					* recode special codes as missing
						recode pre_q15_a_concern_1 (0 96 97 99 = .), g(pre_q15_a_concern_1_REC1)
							lab val pre_q15_a_concern_1_REC1 PRE_Q15_REC
							lab var pre_q15_a_concern_1_REC1 "First biggest concern at present"
					
			* second biggest concern		
					* recode special codes as missing
						recode pre_q15_b_concern_2 (0 96 97 99 = .), g(pre_q15_b_concern_2_REC1)
							lab val pre_q15_b_concern_2_REC1 PRE_Q15_REC
							lab var pre_q15_b_concern_2_REC1 "Second biggest concern at present"
					
			* third biggest concern
					* recode special codes as missing
						recode pre_q15_c_concern_3 (0 96 97 99 = .), g(pre_q15_c_concern_3_REC1)
							lab val pre_q15_c_concern_3_REC1 PRE_Q15_REC
							lab var pre_q15_c_concern_3_REC1 "Third biggest concern at present"
		* create more general categories for pre_q15
		
		lab def PRE_Q15_REC3 1 "Economic concerns" 2 "Social concerns" 3 "Political concerns" 4 "Security concerns" 96 "Refused" 97 "Don't know" 99 "Not applicable", modify
			recode pre_q15_a_concern_1_REC1 (1/12=1) (13 14 18 21 = 2) (15 16 17 20 30 =3) (19 22 23 24 25 26 27 29=4) (28=.), g(pre_q15_a_concern_1_REC3)
				lab val pre_q15_a_concern_1_REC3 PRE_Q15_REC3
			recode pre_q15_b_concern_2_REC1 (1/12=1) (13 14 18 21 = 2) (15 16 17 20 30 =3) (19 22 23 24 25 26 27 29=4) (28=.), g(pre_q15_b_concern_2_REC3) 
				lab val pre_q15_b_concern_2_REC3 PRE_Q15_REC3
			recode pre_q15_c_concern_3_REC1 (1/12=1) (13 14 18 21 = 2) (15 16 17 20 30 =3) (19 22 23 24 25 26 27 29=4) (28=.), g(pre_q15_c_concern_3_REC3)
				lab val pre_q15_c_concern_3_REC3 PRE_Q15_REC3			

				lab var pre_q15_a_concern_1_REC3 "First biggest concern at present"
				lab var pre_q15_b_concern_2_REC3 "Second biggest concern at present"
				lab var pre_q15_c_concern_3_REC3 "Third biggest concern at present"
				
		*Need even more fine-grained for imputation				
			recode pre_q15_a_concern_1_REC3 (1=1) (2 3=2) (4 =3), g(pre_q15_a_concern_1_REC4)
			recode pre_q15_b_concern_2_REC3 (1=1) (2 3=2) (4 =3), g(pre_q15_b_concern_2_REC4) 
			recode pre_q15_c_concern_3_REC3 (1=1) (2 3=2) (4 =3), g(pre_q15_c_concern_3_REC4)
							
		lab def PRE_Q15_REC4 1 "Economic concerns" 2 "Social/Political concerns" 3 "Security concerns", modify
				lab val pre_q15_a_concern_1_REC4 PRE_Q15_REC4
				lab val pre_q15_b_concern_2_REC4 PRE_Q15_REC4
				lab val pre_q15_c_concern_3_REC4 PRE_Q15_REC4			

				lab var pre_q15_a_concern_1_REC4 "First biggest concern at present"
				lab var pre_q15_b_concern_2_REC4 "Second biggest concern at present"
				lab var pre_q15_c_concern_3_REC4 "Third biggest concern at present"

recode pre_q3_sect (0 97=.) (2=2) (3=3) (1 4 5 6 7 8=1), g(pre_q3_sect_REC3)

*Correct missing confession information on the pre-treat survey with info from the screening survey
		replace pre_q3_sect_REC3=1 if scr_q8_sect==1 & pre_q3_sect_REC3==.
		replace pre_q3_sect_REC3=2 if scr_q8_sect==2 & pre_q3_sect_REC3==.
		replace pre_q3_sect_REC3=3 if scr_q8_sect==3 & pre_q3_sect_REC3==.


recode pre_q9_class (96 97=.), g(pre_q9_class_REC1)			
recode pre_q9_class_REC1 (1/2=2) (3=1) (4/5=0), g(pre_q9_class_REC3b)

			lab def PRE_Q1 1 "Male" 2 "Female", modify
				recode pre_q1_gender (2=1) (1=2) 
				lab val pre_q1_gender PRE_Q1
				recode pre_q1_gender (2=1) (1=0), g(pre_q1_gender_REC2)
			lab def PRE_Q1_v2 0 "Male" 1 "Female", modify	
				lab val pre_q1_gender_REC2 PRE_Q1_v2
				lab var pre_q1_gender_REC2 "Gender"
				
	foreach var of varlist pre_q8_income pre_q10_diffecon pre_q11_a_zaimhelp pre_q11_b_relhelp ///
		pre_q4_changesect pre_q5_diffsect pre_q12_a_marry pre_q12_b_doctor pre_q12_c_neighbor ///
		pre_q12_d_poltalk pre_q12_e_econtalk pre_q12_f_supervisor pre_q12_g_friends pre_q14_f_occupation ///
		pre_q7_a_friends pre_q7_b_elites pre_q7_c_petition pre_q7_d_protest pre_q13_disagree ///
		pre_q14_a_agegrp pre_q14_b_gender pre_q14_c_confession pre_q14_d_class pre_q14_e_lebanese {
		recode `var' (96 97=.), g(`var'_REC1) 
	}

*pre_q6_polparty
recode pre_q6_polparty (96 97 =.), g(pre_q6_polparty_REC1)
		lab def PRE_Q6_REC3	1 "Supports a sectarian party" 2 "Supports a non-sectarian party" 3 "Does not support a party", modify
recode pre_q6_polparty_REC1 (1 2 3 4 5 6 9 10 11 15 16=1) (7 8 12 13 14 17=2)  (18=3), g(pre_q6_polparty_REC3)
			lab val pre_q6_polparty_REC3 PRE_Q6_REC3
			lab var pre_q6_polparty_REC3 "Type of political party with strongest support"
			

*POST TREATMENT SURVEY
foreach var of varlist post_q1_a_express post_q1_b_justified post_q1_c_selfish post_q1_d_hiding post_q1_e_changemind ///
		post_q1_f_serious post_q1_g_learned post_q1_h_empthem post_q1_i_empyou post_q1_j_anxious ///
		post_q2_simconcerns post_q3_surprise_econ post_q4_agreechange post_q5_surprise_sect post_q6_overall /// 
		post_q8_a_low_sun post_q8_b_low_chr post_q8_c_low_shi post_q8_d_upp_sun post_q8_e_upp_chr ///
		post_q9_a_lchr_uchr post_q9_b_lsun_usun post_q9_c_lshi_ushi post_q9_d_lshi_lsun post_q9_e_lsun_lchr ///
		post_q9_f_lchr_lshi post_q9_g_ushi_usun post_q9_h_usun_uchr post_q9_i_uchr_ushi ///
		post_q10_a_enemies post_q10_b_worry post_q10_c_unsure post_q11_electionlaw post_q12_marriage ///
		post_q13_a_talksame post_q13_b_talkother post_q13_c_petition post_q13_d_protestsame ///
		post_q13_e_protestother post_q13_f_talkelites post_q13_g_ngo post_q7_knowppl post_q8_f_upp_shi {
		recode `var' (96 97=.), g(`var'_REC1) 
	}

recode post_q14_domidentity (4=1) (1=2) (5=3) (2=4) (3=5) (96 97=.), g(post_q14_domidentity_REC1b)

*** Public Goods Games, Map Exercises, and Petition Signing

recode pet_sign (96=.), g(pet_sign_REC1)

	foreach var of varlist me_beirut me_baalbek me_hasbaya me_hermel me_rashaya me_westbekaa me_zahle me_aley me_baabda me_chouf me_jbeil me_keserwan me_metn me_bintjbeil me_marjayoun me_nabatieh me_akkar me_batroun me_becharre me_koura me_minieh me_tripoli me_zgharta me_jezzine me_saida me_sour {
		recode `var' (0=.) if map_alloc_tot==0, g(`var'_REC1) copyrest
			}

	foreach var of varlist me_beirut_REC1 me_baalbek_REC1 me_hasbaya_REC1 me_hermel_REC1 me_rashaya_REC1 me_westbekaa_REC1 me_zahle_REC1 me_aley_REC1 me_baabda_REC1 me_chouf_REC1 me_jbeil_REC1 me_keserwan_REC1 me_metn_REC1 me_bintjbeil_REC1 me_marjayoun_REC1 me_nabatieh_REC1 me_akkar_REC1 me_batroun_REC1 me_becharre_REC1 me_koura_REC1 me_minieh_REC1 me_tripoli_REC1 me_zgharta_REC1 me_jezzine_REC1 me_saida_REC1 me_sour_REC1 {
		replace `var' = `var'/map_alloc_tot
			}

save "$data_newimp/Leb_1_Prep_FINAL.dta", replace






